/*
 * @Date: 2025-06-13 11:12:23
 * @Auth: 463997479@qq.com
 * @LastEditors: 463997479@qq.com
 * @LastEditTime: 2025-08-29 16:03:31
 * @FilePath: \corpus\src\pages\Home\index.tsx
 */
/*
 * @Date: 2025-06-13 11:12:23
 * @Auth: 463997479@qq.com
 * @LastEditors: 463997479@qq.com
 * @LastEditTime: 2025-06-17 15:31:47
 * @FilePath: \corpus\src\pages\Home\index.tsx
 */
import React, { useEffect } from 'react';

import type { ListItem } from '@/services/ant-design-pro/typings';
import { Card, Col, Empty, Row, Spin, Tabs } from 'antd';
import CompletedApplyKnowledge from './component/CompletedApplyKnowledge';
import List from './component/List';
import MyApplyKnowledge from './component/MyApplyKnowledge';
import EditCorpus from './EditCorpus';
import hooks from './hooks/useHooks';
import styles from './index.less';

import MyToDoKnowledge from './component/MyToDoKnowledge';

const Home: React.FC = (props: any) => {
  const { getKnowledgeIndex, activeKey, dataList, setActiveKey } = hooks.useContainer();
  useEffect(() => {
    getKnowledgeIndex.run({});
  }, []);
  const onChange = (key: string) => {
    setActiveKey(key);
  };
  return (
    <>
      <Row gutter={16}>
        <Col span={5}>
          <Card variant="borderless">
            <div className={styles.title}>{dataList?.data?.gr ?? 0}</div>
            <div className={styles.name}>个人知识库</div>
          </Card>
        </Col>
        <Col span={5}>
          <Card variant="borderless">
            <div className={styles.title}>{dataList?.data?.bm ?? 0}</div>
            <div className={styles.name}>部门知识库</div>
          </Card>
        </Col>

        <Col span={5}>
          <Card variant="borderless">
            <div className={styles.title}>{dataList?.data?.gg ?? 0}</div>

            <div className={styles.name}>公共知识库</div>
          </Card>
        </Col>
        <Col span={5}>
          <Card variant="borderless">
            <div className={styles.title}>{dataList?.data?.cj ?? 0}</div>

            <div className={styles.name}>政务基础语料库</div>
          </Card>
        </Col>
        <Col span={4}>
          <Card variant="borderless">
            <div className={styles.title}>{dataList?.data?.cj ?? 0}</div>

            <div className={styles.name}>城市治理基础语料库</div>
          </Card>
        </Col>
      </Row>
      <div style={{ marginTop: '20.0px' }} className={styles.wrapperContent}>
        <Tabs
          onChange={onChange}
          type="card"
          items={[
            {
              label: `我的待办`,
              key: '1',
            },
            {
              label: `已办事项`,
              key: '2',
            },
            {
              label: `我的申请`,
              key: '3',
            },
          ]}
        />
        {activeKey === '1' ? (
          <MyToDoKnowledge />
        ) : activeKey === '2' ? (
          <CompletedApplyKnowledge />
        ) : (
          <MyApplyKnowledge />
        )}
      </div>
      <div style={{ marginTop: '20.0px' }} className={styles.wrapperContent}>
        <Spin spinning={getKnowledgeIndex.loading}>
          <Row gutter={20} className={styles.wrapper}>
            {dataList?.data?.cyzsk?.length !== 0 ? (
              dataList?.data?.cyzsk?.map((item: ListItem, index: number) => {
                return (
                  <List
                    style={{ cursor: 'default', boxShadow: 'none' }}
                    show={false}
                    item={item}
                    key={index}
                  />
                );
              })
            ) : (
              <div
                style={{
                  width: '100%',
                  display: 'flex',
                  alignItems: 'center',
                  justifyContent: 'center',
                }}
              >
                <Empty />
              </div>
            )}
          </Row>
        </Spin>

        <div className={styles.footer}></div>
      </div>
      <EditCorpus />
    </>
  );
};

export default () => {
  return (
    <hooks.Provider>
      <Home />
    </hooks.Provider>
  );
};
